package com.cat.dataStructure;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/number-of-zero-filled-subarrays/description/?envType=daily-question&envId=2025-08-19
 * @create 2025/8/19 09:15
 * @since JDK17
 */

public class Solution31 {
    public long zeroFilledSubarray(int[] nums) {
        long ans = 0;
        int n = nums.length;
        for (int l = 0, r = 0; r < n; l = ++r) {
            if (nums[r] != 0) { //
                continue;
            }
            while (r < n && nums[r] == 0) { //
                r++;
            }
            ans += (r - l + 1) * (r - l) / 2;
        }

        return ans;
    }
}
